﻿@using zichan.Entity
@using zichan.Common;
@model IPagedList<CabinetClass>
@{
    ViewBag.Title = "机柜用途分类管理";
}

@section Pagetitle{
    @AdminCommon.PageTitle("机柜用途分类管理", "添加/删除/修改")
}
<style>
    #pagebar li {
        display: inline-block;
    }
</style>
<div class="portlet">
    <div class="portlet-title">
        <div class="caption ">
            <i class="fa fa-table"></i>机柜用途分类列表
        </div>
        <div class="actions pull-left leftMargin">
            @if (zichan.Common.PowerHelp.Check("CabinetClass", "create"))
            {
                <a href="@Url.Action("create", "CabinetClass")" class="btn default yellow-stripe">
                    <i class="fa fa-plus"></i>
                    <span class="hidden-480">添加用途分类</span>
                </a>
            }
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-container">

            <div class="dataTables_wrapper dataTables_extended_wrapper no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-group-actions pull-left">
                            @using (Html.BeginForm("index", "CabinetClass", FormMethod.Get, new { @class = "form-inline" }))
                            {
                                <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                <div class="form-group">
                                    <input type="text" placeholder="用途分类" name="name" value="@ViewBag.name" class="form-control input-small input-sm" />
                                </div>
                                <button class="btn btn-sm yellow table-group-action-submit"><i class="fa fa-check"></i> 搜索</button>
                            }
                        </div>
                    </div>
                </div>
                <div class="table-scrollable">
                    <table class="table  table-hover">
                        <thead>
                            <tr class="heading">
                                <th> 序号 </th>
                                <th>机柜用途</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (CabinetClass r in Model)
                            {
                                <tr>
                                    <td>@r.Sort</td>
                                    <td>@r.Purpose</td>
                                    <td>
                                        @if (PowerHelp.Check("CabinetClass", "edit"))
                                        {
                                            <a href="@Url.Action("edit", "CabinetClass", new {id=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-edit"></i> 编辑
                                            </a>
                                        }

                                        @if (PowerHelp.Check("CabinetClass", "delete") && r.UseCount == 0&&r.Id!=1&&r.Id!=2)
                                        {
                                            @*<a href="@Url.Action("delete", "CabinetClass", new { id = r.Id })" class="btn default btn-xs black">*@
                                            <a class="btn default btn-xs black" href="javascript:if(confirm('确定要删除@(r.Purpose)?'))location='/CabinetClass/delete?id=@r.Id'">
                                                <i class="fa fa-trash-o"></i> 删除
                                            </a>
                                        }
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-sm-12 dataTables_paginate">
                        <div class="pull-right">
                            <ul id="pagebar" style="display:inline-block;margin-right:10px;">
                                <li>
                                    每页<select name="pageSize" id="pageSize" class="select2" style="width:50px;font-size:18px;">
                                        <option value="@ViewBag.pageSize">@ViewBag.pageSize</option>
                                        @foreach (var s in ViewBag.pageSizes)
                                        {
                                            <option value="@s.Value">@s.Text</option>
                                        }
                                    </select>个
                                </li>
                                <li>第@(Model.PageNumber)/共@(Model.PageCount)页</li>
                                @using (Html.BeginForm("index", "CabinetClass", FormMethod.Get, new { @style = "display: inline-block;" }))
                                {
                                    <li style="display:none;">
                                        <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                        <input type="hidden" name="name" value="@ViewBag.name" />
                                        @Html.TextBox("pageCount", Model.PageCount)
                                    </li>
                                    <li>跳转至<input name="selectedPage" style="width:40px;font-size:18px;" value="@ViewBag.selectedPage" />页</li>
                                    <li><button type="submit">GO</button></li>}
                            </ul>@if (Model.PageCount > 1)
                            {
                            <ul id="pagebar" class="pagination" style="margin:0px;float:right;">
                                <li><a href="@Url.Action("Index", "CabinetClass", new { name = ViewBag.name,pageSize = ViewBag.pageSize, page = 1 })">首页</a></li>
                                <li>@Html.ActionLink("上一页", "Index", "CabinetClass", new { name = ViewBag.name, pageSize = ViewBag.pageSize, page = Model.PageNumber - 1 }, null)</li>
                                <li>@Html.ActionLink("下一页", "Index", "CabinetClass", new { name = ViewBag.name, pageSize = ViewBag.pageSize, page = (Model.PageNumber + 1 < Model.PageCount ? Model.PageNumber + 1 : Model.PageCount) }, null)</li>
                                <li>@Html.ActionLink("末页", "Index", "CabinetClass", new { name = ViewBag.name, pageSize = ViewBag.pageSize, page = Model.PageCount }, null)</li>
                            </ul>}
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
@section footer{
    <script type="text/javascript">
        $(function () {
            $('#pageSize').on("change", function () {
                var name = $("input[name='name']").val();
                var size = $(this).val();
                location.href = "/CabinetClass/Index?name=" + name +"&pageSize=" + size;
            });
        });
       
    </script>
}
